/**
 * @param {Array} params = [ids]
 */
const db=uniCloud.database()
module.exports = async function(params = []) {
	const clientInfo = this.getUniversalClientInfo()
	const dbJQL = uniCloud.databaseForJQL({
		clientInfo
	})

	let res1 = await dbJQL.collection('wjf-management-persons').where(`'user_id in ${JSON.stringify(params)}'`)
		.remove()
	// let res2 = []
	for (var i = 0; i < params.length; i++) {
		let r = await dbJQL.collection('uni-id-users').doc(params[i]).field('register_env.appid').get({
			getOne: true
		})
		await db.collection('uni-id-users').doc(params[i]).update({
			dcloud_appid:[r.data.register_env.appid],
			shop_id:db.command.remove(), //使用db.command删除shop_id字段
			role:[]
		})
		// res2.push(r.data.register_env.appid)
	}

	return {
		errCode: 0,
		errMsg: 'delete-success'
	}
}